package com.community.owner.domain.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T>{
    private Integer code; //响应编码
    private String msg;// 响应的消息
    private T data; // 响应的数据

    //1. ok 带数据/不带数据
    public static <T> Result<T> ok(){
        return new Result<>(200,"操作成功",null);
    }

    public static <T> Result<T> ok(T obj){
        return new Result<>(200,"操作成功",obj);
    }
    public static <T> Result<T> ok(T obj,String msg){
        return new Result<>(200,msg,obj);
    }

    //失败的情况
    public static <T> Result<T> fail(){
        return new Result<>(500,"操作失败",null);
    }
    public static <T> Result<T> fail(String obj){
        return new Result<>(500,obj,null);

    }


}
